package com.foreknow.oopTest;

/**
 * @author shkstart
 * @create 2021-07-23 13:37
 */
public class Rectangle {
    private int length;
    private int width;

    public Rectangle() {
    }

    public Rectangle(int length, int width) {
        this.length = length;
        this.width = width;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    /**
     * 求面积
     * @return
     */
    public int getArea(){
        return this.getLength()*this.getWidth();
    }

    /**
     * 求周长
     * @return
     */
    public int getPer(){
        return (this.getLength()+this.getWidth())*2;
    }

    public void showAll(){
        System.out.println("长"+this.getLength()+",宽"+this.getWidth()+",面积"+this.getArea()+",周长"+this.getPer());
    }

    public static void main(String[] args) {
        Rectangle rectangle=new Rectangle(2,3);
        rectangle.showAll();
    }
}
